package main

import "fmt"

func main() {
	standardLoop()
	useRnageLoop()
	forWhile()
}

func standardLoop() {
	alphas := []string{"abc", "def", "ghi"}

	// standard for loop
	for i := 0; i < len(alphas); i++ {
		fmt.Printf("%d: %s \n", i, alphas[i])
	}

	// counting backwards
	for i := len(alphas) - 1; i >= 0; i-- {
		fmt.Printf("%d: %s \n", i, alphas[i])
	}
}

func useRnageLoop() {
	alphas := []string{"abc", "def", "ghi"}
	for i, val := range alphas {
		fmt.Printf("%d: %s \n", i, val)
	}
}

func forWhile() {
	x := 0
	for x < 10 {
		fmt.Println(x)
		x++
	}
}

// 无限循环
func infiniteLoop() {
	for {
		fmt.Print(".")
	}
}
